﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    <link href='http://fonts.googleapis.com/css?family=Roboto:400,100&subset=latin,cyrillic-ext,latin-ext,cyrillic' rel='stylesheet' type='text/css'>
    <style type="text/css">
        body, html {
            height: 100%;
            margin: 0px;
            padding: 0px;
        }
        #header {
            background: #267AF0;
            width: 100%;
            height: 40px;
        }
        #logo_container {
            position: relative;
            top: 5px;
            margin-left: 5px;
        }
        #logo {
            position: relative;
            background: white;
            height: 30px;
            width: 30px;
            float: left;
        }
        #logo_text {
            top: -1px;
            margin-left: 3px;
            position: relative;
            font-family: Century Gothic;
            color: white;
            float: left;
            line-height: 16px;
            font-size: 20px;
        }
        #settings {
            position: relative;
            width: 40px;
            height: 40px;
            float: right;
            top: -35px;
        }
        #content {
            margin: 0px;
            margin-top: 15px;
            position: absolute;
            width: 100%;
            height: calc(100% - 55px);
        }
        #form {
            width: 250px;
            position: relative;
            background-color: #101010;
            margin-left: auto;
            margin-right: auto;
            margin-top: 100px;
            text-align: center;
            padding-top: 10px;
            padding-bottom: 10px;
            border-radius: 4px;
            box-shadow: #494949 2px 2px 6px;
        }
        #form > input[type="text"], input[type="password"] {
            width: 90%;
            position: relative;
            border-radius: 3px;
            border: none;
            padding: 4px;
            box-shadow: inset 1px 1px 7px rgba(0, 0, 0, 0.5);
        }
        #form > input[type="button"] {
            outline: none;
            width: 100px;
            margin-top: 5px;
            margin-left: auto;
            margin-right: auto;
            position: relative;
            color: white;
            font-family: 'Roboto', sans-serif;
            font-weight: 300;
            font-size: 0.9em;
            background-color: transparent;
            border: solid 2px white;
            border-radius: 3px;
            opacity: 0.8;
            padding: 6px;
        }
        #form > input[type="button"]:hover {
            opacity: 1;
        }
        #form > p {
            font-family: 'Roboto', sans-serif;
            font-weight: 300;
            color: white;
            font-size: 0.9em;
        }
    </style>
    <script type="text/javascript">

        window.addEventListener("load", init);

        function init()
        {
            document.getElementById("password").onkeydown = function (e)
            {
                if (e.keyCode == 13)
                    login();
            };
            document.getElementById("login").onclick = function () { login(); };
        }

        function login()
        {
            var logMsg = document.getElementById("form_message");

            var username = document.getElementById("username");
            var password = document.getElementById("password");

            if (username.value.length == 0 || password.value.length == 0) {
                logMsg.innerHTML = "Niste uneli potrebne podatke!";
                return;
            }

            var formData = new FormData();
            formData.append("username", username.value);
            formData.append("password", password.value);

            var xmlhttp = new XMLHttpRequest();
            xmlhttp.onreadystatechange = function () {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                    var jsonObject = JSON.parse(xmlhttp.responseText);
                    if (jsonObject.id != -1) {
                        window.location.replace("http://www.balkanreporter.rs/public/admin/adminpanel");
                        //logMsg.innerHTML = "Prijavljeni ste kao:<br/>" + jsonObject.ime + " " + jsonObject.prezime;
                    }
                    else {
                        logMsg.innerHTML = "Neuspešna prijava!";
                        var timer = setInterval(function () {
                            logMsg.innerHTML = "Unesite parametre za pristup:";
                            clearInterval(timer);
                        }, 3500);
                    }
                }
            }
            xmlhttp.open("POST", "http://www.balkanreporter.rs/public/admin/login", true);
            xmlhttp.send(formData);
        }

    </script>
</head>
<body>
    <div id="header">
        <div id="logo_container">
            <div id="logo"></div>
            <div id="logo_text">Balkan<br />Reporter</div>
        </div>
    </div>
    <div id="content">
        <div id="form">
            <p id="form_message">Unesite parametre za pristup:</p>
            <input id="username" type="text" placeholder="korisnicko ime" />
            <input id="password" type="password" placeholder="lozinka" />
            <input id="login" type="button" value="Prijavi se" />
        </div>
    </div>
</body>
</html>